import javax.swing.*;

import java.awt.event.*;
import java.util.*;
import java.io.*;

public class filewalker{
	
	public static String walkTVShows(File dir){
		File[] list2 = dir.listFiles();
		String output = "";
		for (int i = 0; i < list2.length; i++) {
			output+= list2[i].getAbsolutePath() + "\n";
			if(list2[i].isDirectory()){
				File subDir = new File(list2[i].getAbsolutePath());
				output += walkSeasons(subDir,list2[i].getName());
			}else{
				System.out.println("FILE SHOUDNT BE HERE \n");
			}
		}
		return output;
	}
	
	public static String walkSeasons(File dir, String showName){
		File[] list2 = dir.listFiles();
		String output = "";

		for (int i = 0; i < list2.length; i++) {
			output+= list2[i].getAbsolutePath() + "\n";
			if(list2[i].isDirectory()){
				File subDir = new File(list2[i].getAbsolutePath());
				output += walkEpisodes(subDir, showName, list2[i].getName());
			
			}		
		}
		return output;
	}
	public static String walkEpisodes(File dir, String showName, String seasonNumb){
		File[] list2 = dir.listFiles();
		String output = "";

		for (int i = 0; i < list2.length; i++) {
			output+= list2[i].getAbsolutePath() + "\n";
			if(list2[i].isDirectory()){
				output += "shoudnt get here \n";
			
			}	else{
				list2[i].renameTo(new File(dir,showName+"S"+seasonNumb+"E"+i+"test.txt"));
			}	
		}
		return output;
	}


	public static void main(String s[]) {
			File dir = new File("C:\\filewalker");
			guiFrame frame = new guiFrame();
			frame.setVisible(true);
			JFileChooser chooser = new JFileChooser(dir);
		    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		    frame.add(chooser);
		    chooser.setVisible(true);
		    
			//int ret = chooser.showDialog(null, "Open File");
		    {
		    	File file = chooser.getSelectedFile();
		    	System.out.println(walkTVShows(file));
		    }
			
			
			
			

	}
	



	
}
